/****************************************************************************
 *
 * Copyright (C) 2003-2008 Los Alamos National Security, LLC
 *                         Packet Analytics Corporation
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License Version 2 as
 * published by the Free Software Foundation.  You may not use, modify or
 * distribute this program under any other version of the GNU General
 * Public License.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 *
 ****************************************************************************/
package nfse.dataset.tippingpoint;

import java.sql.Timestamp;
import nfse.NetFSE;
import nfse.NetFSERecord;
import nfse.NetFSEUtil;

/*******************************************************************************
 * This class is used to parse and store TippingPoint records.
 * 
 * @author
 * 
 * This code is the property of Los Alamos National Laboratory and the
 * University of California, Copyright 2005
 */
public class TippingPointRecord extends NetFSERecord {

    /***************************************************************************
     * Defines what version of the log format was used to generate this object
     */
    public int type = -1;

    /***************************************************************************
     * Flag indicating if this is a Peer-to-peer record
     */
    public boolean p2p = false;

    /***************************************************************************
     * Text string representing the protocol for this block (e.g. "TCP", "UDP")
     */
    public String protocol = "";

    /***************************************************************************
     * The TCP source port for this block represented
     */
    public int srcPort = -1;

    /***************************************************************************
     * The TCP destination port for this block represented
     */
    public int dstPort = -1;

    /***************************************************************************
     * The destination IP address for this block represented as a 32-bit integer
     */
    public long dstIP = -1;

    /***************************************************************************
     * Text representation of the version of the sensor that generated this block
     */
    public String version = "";

    /***************************************************************************
     * The time when the block took place
     */
    public Timestamp ts1 = null;

    /***************************************************************************
     * The time when the log was generated
     */
    public Timestamp ts2 = null;

    /***************************************************************************
     * Text description of the sensor that generated this block
     */
    public String sensorName = "";

    /***************************************************************************
     * Not sure what this value represents
     */
    public long seqNum = -1;

    /***************************************************************************
     * The type of action that was taken
     */
    public String action = "";

    /***************************************************************************
     * A label indicating the threat level associated with this event
     */
    public String severity = "";

    /***************************************************************************
     * Not sure what this value represents
     */
    public String policyUUID = "";

    /***************************************************************************
     * Identifier for this alert signature
     */
    public int alertID = -1;

    /***************************************************************************
     * Type of this alert signature
     */
    public String alertType = "";

    /***************************************************************************
     * Description of this alert signature
     */
    public String alertDesc = "";
    
    public boolean isAlert() {
        return true;
    }
    
    public String getAlertMessage() {
        return this.alertDesc;
    }
    
    public Timestamp getStartTS() {
        return ts1;
    }
    
    public void setDstPort(int dstPort) {
        this.dstPort = dstPort;
    }

    public long getDstIP() {
        return dstIP;
    }

    public int getProtocol() {
        return NetFSEUtil.getProtocolValue(protocol);
    }

    public int getDstPort() {
        return dstPort;
    }
    
    public int[] getIndexedFields() {
        int[] temp =  {NetFSE.FIELD_START_TS, NetFSE.FIELD_DST_IP, NetFSE.FIELD_SRC_IP, NetFSE.FIELD_DST_PORT };
        return temp;
    }
 
    @Override
    public String getDstAddr() {
        if (getDstIP() < 0)
            return null;
        return NetFSEUtil.convertLongToIP(getDstIP());
    }

    public void setDstIP(long dstIP) {
        this.dstIP = dstIP;
    }

    
    

}